<?php
class Time_utils {
	
	public function get_today()
	{
		return date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d"), date("Y")));
	}
	
	public function get_tomorrow()
	{
		return date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
	}
	
	public function get_next_day($interval)
	{
		return date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d") + $interval, date("Y")));
	}

	public function get_today_range()
	{
		$from = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d"), date("Y")));
		$to = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("d"), date("Y")));
		return array($from, $to);
	}

	public function get_yesterday_range()
	{
		$from = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d") - 1, date("Y")));
		$to = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("d") - 1, date("Y")));
		return array($from, $to);
	}

	public function get_week_range()
	{
		$from = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), date("d") - date("w") + 1, date("Y")));
		$to = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y")));
		return array($from, $to);
	}
	
	public function get_current_month_range()
	{
		$from = date("Y-m-d H:i:s", mktime(0, 0, 0, date("m"), 1, date("Y"))); 
		$to = date("Y-m-d H:i:s", mktime(23, 59, 59, date("m"), date("t"), date("Y"))); 
		return array($from, $to);
	}
	
	public function get_month_range($year, $month)
	{
		$from = date("Y-m-d H:i:s", mktime(0, 0, 0, $month, 1, $year));
		$to = date("Y-m-d H:i:s", mktime(23, 59, 59, $month + 1, 0, $year));
		return array($from, $to);
	}
}
?>